import { createRouter, createWebHistory } from 'vue-router'
import AnomalyDetectionView from '../views/AnomalyDetection.vue'
import SmartAssistantView from '../views/SmartAssistantView.vue'
import KnowledgeGraphView from '../views/KnowledgeGraphView.vue'
import FaultInfoView from '../views/FaultInfoView.vue'
import HomePage from '../views/HomePage.vue'
// 您可能需要创建其他视图组件，例如：
// import RealtimeMonitoringView from '../views/RealtimeMonitoringView.vue';
// import RiskWarningView from '../views/RiskWarningView.vue';
// import OperationHandlingView from '../views/OperationHandlingView.vue';

const routes = [
  {
    path: '/',
    name: 'Home',
    component: HomePage,
    meta: { title: '首页' },
  },
  {
    path: '/anomaly-detection',
    name: 'AnomalyDetection',
    component: AnomalyDetectionView,
    meta: { title: '智能运维 - 超实时预测' },
  },
  {
    path: '/smart-assistant', // 新页面的路径
    name: 'SmartAssistant',
    component: SmartAssistantView, // 对应的组件
    meta: { title: '智能助手' },
  },
  {
    path: '/knowledge-graph', // 新页面的路径
    name: 'KnowledgeGraph',
    component: KnowledgeGraphView, // 对应的组件
    meta: { title: '设备运维知识图谱' },
  },
  {
    path: '/fault-info', // 新页面的路径
    name: 'FaultInfo',
    component: FaultInfoView, // 对应的组件
    meta: { title: '故障信息' },
  },
  // 可以添加其他路由：
  // {
  //   path: '/realtime-monitoring',
  //   name: 'RealtimeMonitoring',
  //   component: RealtimeMonitoringView,
  //   meta: { title: '实时监控' }
  // },
  // {
  //   path: '/risk-warning',
  //   name: 'RiskWarning',
  //   component: RiskWarningView,
  //   meta: { title: '风险预警' }
  // },
  // {
  //   path: '/operation-handling',
  //   name: 'OperationHandling',
  //   component: OperationHandlingView,
  //   meta: { title: '操作处置' }
  // },
  // 404 Not Found 路由
  // {
  //   path: '/:catchAll(.*)', // 匹配所有未定义的路由
  //   name: 'NotFound',
  //   component: () => import('../views/NotFoundView.vue'), // 假设您创建了一个 NotFoundView.vue
  // },
]

const router = createRouter({
  history: createWebHistory(), // 使用 HTML5 History 模式
  routes,
})

// 可选：全局前置守卫，用于修改页面标题
router.beforeEach((to, from, next) => {
  if (to.meta.title) {
    document.title = to.meta.title
  } else {
    document.title = '智能运维平台' // 默认标题
  }
  next()
})

export default router
